{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# http://api.mongodb.com/python/current/tutorial.html\n",
    "import pymongo\n",
    "import pprint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "client = pymongo.MongoClient(\"mongodb://spiderrd:spiderrd@45.32.68.44:37017/bilibili_spider\")\n",
    "db = client.bilibili_spider\n",
    "member_card = db.member_card"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'DisplayRank': '0',\n",
       " '_id': ObjectId('5a8ed520b09d9a3c4000d53b'),\n",
       " 'approve': False,\n",
       " 'archive_count': 1,\n",
       " 'article': 0,\n",
       " 'attention': 0,\n",
       " 'attentions': [],\n",
       " 'birthday': '',\n",
       " 'ctime': '2018-02-22 22:32:50',\n",
       " 'description': '',\n",
       " 'face': 'http://i2.hdslb.com/bfs/face/de17baa65d6478ee7fe55a5c0528854247334f2d.gif',\n",
       " 'fans': 0,\n",
       " 'friend': 0,\n",
       " 'level_info': {'current_exp': 3920,\n",
       "  'current_level': 3,\n",
       "  'current_min': 1500,\n",
       "  'next_exp': 4500},\n",
       " 'mid': 32000,\n",
       " 'name': '无枫',\n",
       " 'nameplate': {'condition': '',\n",
       "  'image': '',\n",
       "  'image_small': '',\n",
       "  'level': '',\n",
       "  'name': '',\n",
       "  'nid': 0},\n",
       " 'official_verify': {'desc': '', 'type': -1},\n",
       " 'pendant': {'expire': 0, 'image': '', 'name': '', 'pid': 0},\n",
       " 'place': '',\n",
       " 'rank': '10000',\n",
       " 'regtime': 0,\n",
       " 'sex': '男',\n",
       " 'sign': '',\n",
       " 'spacesta': 0,\n",
       " 'vip': {'accessStatus': 1,\n",
       "  'dueRemark': '',\n",
       "  'vipDueDate': 0,\n",
       "  'vipStatus': 0,\n",
       "  'vipStatusWarn': '',\n",
       "  'vipType': 0}}"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "member_card.find_one()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'DisplayRank': '0',\n",
      " '_id': ObjectId('5a91fe0f979a0f5c461ff290'),\n",
      " 'approve': False,\n",
      " 'archive_count': 17,\n",
      " 'article': 0,\n",
      " 'attention': 43,\n",
      " 'attentions': [31782714,\n",
      "                26728556,\n",
      "                510196,\n",
      "                4495971,\n",
      "                10010775,\n",
      "                3557916,\n",
      "                949952,\n",
      "                261669819,\n",
      "                8629138,\n",
      "                5760446,\n",
      "                2317414,\n",
      "                1278545,\n",
      "                19190861,\n",
      "                279353518,\n",
      "                13089665,\n",
      "                89225756,\n",
      "                2881659,\n",
      "                8226817,\n",
      "                75304607,\n",
      "                62426742,\n",
      "                94742590,\n",
      "                94177278,\n",
      "                317866,\n",
      "                6355324,\n",
      "                205631797,\n",
      "                28588984,\n",
      "                43413569,\n",
      "                8511003,\n",
      "                88461692,\n",
      "                228267254,\n",
      "                8578857,\n",
      "                3623851,\n",
      "                1446291,\n",
      "                1664494,\n",
      "                20503549,\n",
      "                12735613,\n",
      "                6290510,\n",
      "                5581898,\n",
      "                6711533,\n",
      "                4486494,\n",
      "                2019740,\n",
      "                3766866,\n",
      "                488744],\n",
      " 'birthday': '',\n",
      " 'ctime': '2018-02-25 08:04:36',\n",
      " 'description': '',\n",
      " 'face': 'http://i0.hdslb.com/bfs/face/3a2799018636c9c43774dd7bf6685387bb219011.jpg',\n",
      " 'fans': 507,\n",
      " 'friend': 43,\n",
      " 'level_info': {'current_exp': 14372,\n",
      "                'current_level': 5,\n",
      "                'current_min': 10800,\n",
      "                'next_exp': 28800},\n",
      " 'mid': 2654670,\n",
      " 'name': 'LePtC',\n",
      " 'nameplate': {'condition': '',\n",
      "               'image': '',\n",
      "               'image_small': '',\n",
      "               'level': '',\n",
      "               'name': '',\n",
      "               'nid': 0},\n",
      " 'official_verify': {'desc': '', 'type': -1},\n",
      " 'pendant': {'expire': 0, 'image': '', 'name': '', 'pid': 0},\n",
      " 'place': '',\n",
      " 'rank': '10000',\n",
      " 'regtime': 0,\n",
      " 'sex': '保密',\n",
      " 'sign': '学物理的都好萌～',\n",
      " 'spacesta': 0,\n",
      " 'vip': {'accessStatus': 1,\n",
      "         'dueRemark': '',\n",
      "         'vipDueDate': 1491235200000.0,\n",
      "         'vipStatus': 0,\n",
      "         'vipStatusWarn': '',\n",
      "         'vipType': 1}}\n"
     ]
    }
   ],
   "source": [
    "pprint.pprint(member_card.find_one({\"name\": 'LePtC'}))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2571000\n"
     ]
    }
   ],
   "source": [
    "pprint.pprint(member_card.count())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
